<?php

namespace App\Http\Controllers\Api;

use Illuminate\Http\Request;
use App\Repository\UpThree\ThreeOrderRepository;
use App\Repository\UpThree\MainOrderRepostition;
use App\Repository\Order\OrderRepository;

use Monolog\Logger;
use Monolog\Formatter\LineFormatter;
use Monolog\Handler\RotatingFileHandler;

/**
 * @OA\Tag(
 *     name="后台菜单模块",
 *     description="菜单模块",
 * )
 */
class wxPayNotifyController extends BaseController
{
  public function __construct()
  {
    $this->log = new Logger('WxNotify');
    $this->log->pushHandler(
      (new RotatingFileHandler(storage_path('/logs/WxNotify.log'), 14, Logger::DEBUG, true, 0777))->setFormatter(new LineFormatter(null, null, true, true))
    );
  }
  public function wxnotify(Request $Request)
  {
    $res = $Request;
    $this->log->info('request' . json_encode($res));
    $getData = file_get_contents('php://input');
    $this->log->info('input' . ($getData));
    $getData = '{"id":"b6375eb4-c96e-5240-aed8-7b0181c06e56","create_time":"2022-09-02T20:23:19+08:00","resource_type":"encrypt-resource","event_type":"TRANSACTION.SUCCESS","summary":"支付成功","resource":{"original_type":"transaction","algorithm":"AEAD_AES_256_GCM","ciphertext":"WWRtCBFlgk2GChgbQv1zmT2e6wLo36CtCIhBlPuP8WTMkiywYP0FrZIK9d/mHTCw7dBHDCZUiklCSUe5iqTlCEU6ntuRnfe9dg7M4nDVejLGMHQftGw4wx6B+IJN8jtYYSUY2ZpSBTGw7QsPJKCj7L03OV0TjcH0E1U3/f1YsmfB7SZKvayWmTDI2Q2cZ5+E7qWbh0Acy+Htx8ORxleEMwZWJzLQ34AHFWQyYbMxlpdZQsUkODO5YjU91GYqPRGMvjzO4QW+IEW3kMr2ApiEVk9z+6ZqEEuG42rzdVzqZ/QOmf+xKQJsBz16GKxuP7wTYa8IYMZ7eNviRpQm71u1DgTAjj1FlwrBKt9fmuY+SSG9PHWwIvxNewThCWW18OVhYPkIrs8IvSIUm+6H0XfSQa+kWYez4OGElC2z/xjRQP2w/+yHeEpKsyTx6dPlJO4rDpmW3VpxMtl53WKAVUYDAv+xQhsobfnZAOundvq4fo8X4lKcE69udIrHhBT0Eu8UbcLWHUZP2Fn+hLLwTeLldc+WfpnVWjJaUz6BrQA+MPueRx3x5MUVS+8Z+z4=","associated_data":"transaction","nonce":"exXJVQaGnkgV"}}';
    // 微信支付回调解密
    $data = json_decode($getData, true);

    return json_encode(['code' => 'SUCCESS', 'msg' => '获取成功']);
  }
}
